﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace zkdao.WebImage.Controllers {
    public class PhotoController : Controller {
        public ActionResult Index() {
            return View();
        }
        public ActionResult Upload() {
            return View();
        }
        public JsonResult UploadFiles() {
            List<string> imageIDs = new List<string>();
            foreach (string fileKey in Request.Files.Keys) {
                HttpPostedFileBase file = Request.Files[fileKey];
                if (file.ContentLength <= 0) continue;
                string imageID = PhotoUtils.Save(file, Request.Headers["userKey"]);
                imageIDs.Add(imageID);
            }
            return Json(new { imageIDs = String.Join(",", imageIDs) });
        }

    }
}
